package netnotifier.notification;

import java.util.Arrays;


public class IPv4Packet extends Packet
{
	public int headerLength=0;
	public int totalLength=0;
	public int ttl=0;
	public int protocol=0;
	
	public byte[] sourceIP;
	public byte[] destinationIP;
	
	public static String[] defaultFields={"headerLength","totalLength","ttl","protocol","sourceIP","destinationIP"};
	
	public IPv4Packet(byte[] rawData, int offset)
	{
		headerLength=(rawData[offset]&0x0f);
		headerLength<<=2;
		
		totalLength+=(rawData[offset+2]&0xff);
		totalLength<<=8;
		totalLength+=(rawData[offset+3]&0xff);
		
		ttl=(rawData[offset+8]&0x0f);
		protocol=(rawData[offset+9]&0xff);
		
		sourceIP=Arrays.copyOfRange(rawData,offset+12,offset+16);
		destinationIP=Arrays.copyOfRange(rawData,offset+16,offset+20);
	}
}

